using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using HISModels.Entities;

namespace HISModels.Mapping
{
	public class SysNavigationGroupMap : EntityTypeConfiguration<SysNavigationGroup>
	{
		public SysNavigationGroupMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			this.Property(t => t.DescValue)
				.IsRequired()
				.HasMaxLength(200);
				
			// Table & Column Mappings
			this.ToTable("SysNavigationGroups");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.DescValue).HasColumnName("DescValue");
			this.Property(t => t.RoleId).HasColumnName("RoleId");

			// Relationships
			this.HasOptional(t => t.SysRole)
				.WithMany(t => t.SysNavigationGroups)
				.HasForeignKey(d => d.RoleId);
				
		}
	}
}

